package onlineAccessManagement;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class DBLib {//连接数据库的第二种方式。用的是Server(2)
	public static Connection getconn() throws NamingException, SQLException {
		InitialContext initCtx=new InitialContext();
		DataSource ds=(DataSource) initCtx.lookup("java:comp/env/mytest");
		return ds.getConnection();
	}
}
//得到信息且连接到数据库